<?php

namespace App\Model\Guild;

use Illuminate\Support\Facades\DB;

/**
 * 代理结算
 */
class GuildAccountDaily extends GuildBase
{
    protected $table = 'guild_account_daily';

    public function guildInfo()
    {
        return $this->belongsTo(Guild::class, 'guild_manage_id', 'id');
    }

    public static function getTotal($where=[],$guildInfoId=[])
    {
        return self::where($where)
            ->whereIn('guild_manage_id',$guildInfoId)
            ->select(
                DB::raw('sum(voice_income) as voice_income'),
                DB::raw('sum(video_income) as video_income'),
                DB::raw('sum(msg_income) as msg_income'),
                DB::raw('sum(gift_income) as gift_income'),
                DB::raw('sum(invite_recharge_income) as invite_recharge_income')
            )->first()->toArray();

    }
}
